package com.scu.service;

import com.scu.dao.BlockDao;
import com.scu.pojo.Block;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class BlockServiceImpl implements BlockService{
    @Autowired
    private BlockDao blockDao;

    //获取板块信息
    @Override
    public List<Block> getBlockList(){
        return blockDao.getBlockList();
    }


    /**
     * //分页查询帖子列表
     * @param block
     * @param page
     * @param limit
     * @return
     */
    @Override
    public List<Block> getBlockListByPage(Block block,int page,int limit){
//        System.out.println(block);
//        System.out.println(page);
//        System.out.println(limit);

        return blockDao.getBlockListByPage((page-1)*limit,limit,block);
    }

    //获取版块数
    @Override
    public int getBlockCount(Block block){
        return blockDao.getBlockCount(block);
    }

    //新增版块
    @Override
    public int addBlock(Block block){

        return blockDao.addBlock(block);
    }

    //删除版块
    @Override
    public int removeBlockById(String b_id){
        return blockDao.removeBlockById(b_id);
    }

    //修改板块信息
    @Override
    public int redactBlock(Block block){
        return blockDao.redactBlock(block);
    }

    //获取当前版块帖子数目
    @Override
    public int getTopicNum(String b_id){
        return blockDao.getTopicNum(b_id);
    }
}

